<template>
	<view class="content">
		<!-- 自定义胶囊 -->
		<view class="content_top" :style="'padding-top:'+top+'px'">
			云南省第一人民医院
		</view>
		<!-- 天气 -->
		<view class="weather">
			<image class="image-bg" src="/static/微信图片_20230324195048.png" />
			<view class="weather_top">
				<view class="bj">
					<image style="width: 30px;height: 30px;margin-right: 5px;" :src="weatherList[0].address_icon"
						mode="">
					</image>
					{{weatherList[0].pname}}&ensp;{{weatherList[0].secondaryname}}&ensp;{{weatherList[0].name}}
				</view>
				<view class="tg">
					<image style="width: 30px;height: 30px;margin-right: 5px;" :src="weatherList[0].tigan_icon" mode="">
					</image>体感温度 7°
				</view>
				<view class="zwx">
					<image style="width: 30px;height: 30px;margin-right: 5px;" :src="weatherList[0].ziwxian_icon"
						mode=""></image>紫外线强度
					{{weatherList[0].uvi}}W/m
				</view>
			</view>
			<view class="weather_bottom">
				<view class="y">
					<view class="du">
						{{weatherList[0].realFeel}}°
					</view>
					<image style="width: 30px;height: 30px;margin-right: 10px;" :src="weatherList[0].icon" mode="">
					</image>
					{{weatherList[0].condition}}
				</view>
				<view class="sd">湿度 {{weatherList[0].humidity}}%&emsp;|&emsp;{{weatherList[0].windDir}}
					{{weatherList[0].windLevel}}级
				</view>
				<view class="">{{weatherList[0].tips}}</view>
			</view>
		</view>
		<!-- 导航 -->
		<view class="ul">
			<view class="li" v-for="item,index in navList[0].vaccine" :key="index" @click="goRegister(index)">
				<image class="li_img" :src="item.image" mode=""></image><br>
				{{item.title}}
			</view>
		</view>
		<!-- 预约挂号 -->
		<view class="yy">
			<view class="yy_item" v-for="item,index in navList[1].reserve" :key="index">
				<view class="tit">{{item.title}}</view>
				<view class="des">{{item.describe}}</view>
				<image class="yy_item_img" :src="item.image" mode=""></image>
			</view>
		</view>
		<!-- 热门挂号 -->
		<view class="gh">
			<view class="gh_item" v-for="item in navList[2].popular" :key="item.dep_id"
				:style="'background-color:'+item.background+';'">
				{{item.title}}
				<image class="gh_item_img" :src="item.image" mode=""></image>
			</view>
		</view>
		<!-- 健康自检 -->
		<view class="zj">
			<view class="zj_item" v-for="item,index in navList[3].self_test" :key="index">
				<view class="zj_name">
					{{item.name}}
				</view>
				<view class="zj_des">
					{{item.describe}}
				</view>
				<view class="zj_tex">
					<view class="zj_tex_one">
						{{item.number_of_people}}
					</view>
					<view class="zj_tex_two">
						人测过/{{item.question}}题/{{item.minute}}分钟
					</view>
				</view>
				<image :src="item.image" class="zj_img" mode=""></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		// getWeather,
		getIndexList
	}
	from '../../utils/api.js'
	export default {
		data() {
			return {
				title: '',
				// navHright: 0, // 状态栏高度
				// jnHirght: 0, // 胶囊高度
				top: 0,
				// 天气数据
				weatherList: [],
				// 导航数据
				navList: []
			}
		},
		onLoad() {
			this.fn()
			// 获取经纬度
			this.getLongitude()
			// 获取导航
			this.getIndex()
		},
		methods: {
			// 自定义胶囊
			fn() {
				let a = wx.getMenuButtonBoundingClientRect()
				this.top = a.top
			},
			// 获取经纬度
			getLongitude() {
				let test = this
				wx.getLocation({
					type: 'wgs84',
					success(res) {
						console.log(res);
						// getWeather(res).then(res => {
						// 	test.weatherList = res.data.data
						// })
					}
				})
			},
			// 获取导航数据
			getIndex() {
				getIndexList().then(res => {
					console.log(93, res);
					this.navList = res.data.data
				})
			},
			// 去新冠疫苗页
			goRegister(i) {
				if (i == 0) {
					uni.navigateTo({
						url: '/pages/vaccine/vaccine'
					})
					return
				} else if (i == 2) {
					uni.navigateTo({
						url: '/pages/nucleic/nucleic'
					})
				}
			}
		}
	}
</script>

<style>
	.content_top {
		font-weight: 600;
		line-height: 30px;
		padding-left: 40rpx;
		font-size: 18px;
		background: #344f8f;
		color: #fff;
	}

	.weather {
		height: 330px;
		width: 100%;
		position: relative;
		z-index: 0; // 支付宝小程序下背景不生效时，可以加上这个
		color: #fff;
		padding-top: 10px;
		position: relative;
	}

	.bj {
		font-weight: 600;
		font-size: 20px;
		display: flex;
		align-items: center;
		margin-bottom: 6px;
	}

	.tg {
		font-size: 18px;
		display: flex;
		align-items: center;
		margin-bottom: 6px;
	}

	.zwx {
		font-size: 18px;
		display: flex;
		align-items: center;
		margin-bottom: 6px;
	}

	.weather_bottom {
		width: 300px;
		text-align: center;
		position: absolute;
		left: 50%;
		margin-left: -150px;
		bottom: 30px;
	}

	.y {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.du {
		font-size: 40px;
	}

	.sd {
		margin: 15px;
	}

	.ul {
		width: 100%;
		height: 60px;
		display: flex;
		align-items: center;
		margin: 10px 0;
	}

	.li {
		width: 100%;
		height: 60px;
		text-align: center;
		/* display: flex;
		flex-wrap: wrap;
		justify-content: center; */
	}

	.li_img {
		flex: 1;
		width: 25px;
		height: 30px;
	}

	.yy {
		width: 100%;
		height: 150px;
		display: flex;
		align-items: center;
	}

	.yy_item {
		width: 45%;
		height: 120px;
		padding: 5px;
		border-radius: 10px;
		position: relative;
		background-color: #8ab7ff;
		margin: 0 6px;
	}

	.tit {
		font-size: 20px;
		color: blue;
		margin: 5px 0;
	}

	.des {
		font-size: 18px;
		color: #fff;
	}

	.yy_item_img {
		width: 100px;
		height: 70px;
		position: absolute;
		right: 0;
		bottom: 0;
	}

	.gh {
		width: 100%;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.gh_item {
		width: 29%;
		height: 60px;
		border-radius: 8px;
		margin: 5px 3px;
		padding: 5px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.gh_item_img {
		width: 30px;
		height: 45px;
	}

	.zj {
		width: 100%;
	}

	.zj_des {
		color: #ddd;
		margin: 10px 0 15px 0;
	}

	.zj_item {
		width: 100%;
		height: 120px;
		padding: 5px;
		position: relative;
	}

	.zj_tex {
		display: flex;
		color: #ddd;
		font-size: 14px;
		align-items: center;
	}

	.zj_name {
		font-size: 22px;
	}

	.zj_tex_one {
		font-size: 20px;
		color: #000;
	}

	.zj_img {
		width: 130px;
		height: 130px;
		position: absolute;
		right: 0;
		bottom: 0;
	}
</style>